package cn.swh.guguanjia.mapper;

import cn.swh.guguanjia.entity.QualificationCondition;
import org.springframework.util.StringUtils;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/10/26 11:09
 * @Version: 1.0
 */
public class QualifcationProvider {
    public String selectPage(QualificationCondition condition) {
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT " +
                " qu.*, " +
                " uu.NAME upload_name, " +
                " cu.NAME check_name  " +
                "FROM " +
                " qualification qu " +
                " LEFT JOIN sys_user uu ON qu.upload_user_id = uu.id " +
                " LEFT JOIN sys_user cu ON qu.check_user_id = cu.id  " +
                "WHERE " +
                " qu.del_flag =0 ");
        if(!StringUtils.isEmpty(condition.getStarDate())){
            sb.append( "AND qu.create_date >= #{starDate} ");
        }
        if(!StringUtils.isEmpty(condition.getEndDate())){
            sb.append( "AND qu.create_date <= #{endDate} ");
        }
        if(!StringUtils.isEmpty(condition.getType())){
            sb.append( "AND qu.type = #{type} ");
        }
        if(!StringUtils.isEmpty(condition.getCheck())){
            sb.append( "AND qu.check = #{check} ");
        }
        System.out.println(sb.toString());
        return sb.toString();
    }

}
